<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Adds a solid fill to the shape</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.swfshape.html">SWFShape</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="swfshape.construct.html">SWFShape::__construct</a></div>
 <div class="up"><a href="class.swfshape.html">SWFShape</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="swfshape.addfill" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SWFShape::addFill</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.5)</p><p class="refpurpose"><span class="refname">SWFShape::addFill</span> &mdash; <span class="dc-title">Adds a solid fill to the shape</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-swfshape.addfill-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="class.swffill.html" class="type SWFFill">SWFFill</a></span> <span class="methodname"><strong>SWFShape::addFill</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$red</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$green</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$blue</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$alpha</code><span class="initializer"> = 255</span></span>
  ] )</div>

  <div class="methodsynopsis dc-description">
   <span class="type"><a href="class.swffill.html" class="type SWFFill">SWFFill</a></span> <span class="methodname"><strong>addFill</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.swfbitmap.html" class="type SWFBitmap">SWFBitmap</a></span> <code class="parameter">$bitmap</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>
  ] )</div>

  <div class="methodsynopsis dc-description">
   <span class="type"><a href="class.swffill.html" class="type SWFFill">SWFFill</a></span> <span class="methodname"><strong>addFill</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.swfgradient.html" class="type SWFGradient">SWFGradient</a></span> <code class="parameter">$gradient</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>
  ] )</div>

  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">此函数是<em class="emphasis">实验性</em>的。此函数的表象，包括名称及其相关文档都可能在未来的
PHP 发布版本中未通知就被修改。使用本函数风险自担 。</p></div>
  <p class="para">
   <span class="function"><strong>SWFShape::addFill()</strong></span> adds a solid fill to the shape&#039;s list 
   of fill styles. <span class="function"><strong>SWFShape::addFill()</strong></span> accepts three different
   types of arguments.
  </p>
  <p class="para">
   <em><code class="parameter">red</code></em>, <em><code class="parameter">green</code></em>, <em><code class="parameter">blue</code></em>
   is a color (RGB mode).
  </p>
  <p class="para">
   The <em><code class="parameter">bitmap</code></em> argument is an <span class="function"><strong>SWFBitmap()</strong></span> object.
   The <em><code class="parameter">flags</code></em> argument can be one
   of the following values: SWFFILL_CLIPPED_BITMAP, SWFFILL_TILED_BITMAP,
   SWFFILL_LINEAR_GRADIENT or SWFFILL_RADIAL_GRADIENT. Default is
   SWFFILL_TILED_BITMAP for SWFBitmap and SWFFILL_LINEAR_GRADIENT for
   SWFGradient.
  </p>
  <p class="para">
   The <em><code class="parameter">gradient</code></em> argument is an <span class="function"><strong>SWFGradient()</strong></span> 
   object. The flags argument can be one of the following values :  
   SWFFILL_RADIAL_GRADIENT or SWFFILL_LINEAR_GRADIENT. Default is 
   SWFFILL_LINEAR_GRADIENT. I&#039;m sure about this one. Really. 
  </p>
  <p class="para">
   <span class="function"><strong>SWFShape::addFill()</strong></span> returns an <span class="function"><strong>SWFFill()</strong></span>
   object for use with the <span class="function"><a href="swfshape.setleftfill.html" class="function">SWFShape::setLeftFill()</a></span> 
   and <span class="function"><a href="swfshape.setrightfill.html" class="function">SWFShape::setRightFill()</a></span> functions 
   described below. 
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-swfshape.addfill-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   This simple example will draw a frame on a bitmap. Ah, here&#039;s another buglet in 
   the flash player- it doesn&#039;t seem to care about the second shape&#039;s bitmap&#039;s
   transformation in a morph. According to spec, the bitmap should stretch 
   along with the shape in this example.. 
   <div class="example" id="example-3459">
    <p><strong>Example #1 <span class="function"><strong>SWFShape::addFill()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$p&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SWFMorph</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SWFBitmap</span><span style="color: #007700">(</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">"alphafill.jpg"</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//&nbsp;use&nbsp;your&nbsp;own&nbsp;bitmap<br /></span><span style="color: #0000BB">$width&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getWidth</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$height&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getHeight</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$s&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getShape1</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$f&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addFill</span><span style="color: #007700">(</span><span style="color: #0000BB">$b</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SWFFILL_TILED_BITMAP</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$f</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">moveTo</span><span style="color: #007700">(-</span><span style="color: #0000BB">$width</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">$height</span><span style="color: #007700">/</span><span style="color: #0000BB">4</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$f</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">scaleTo</span><span style="color: #007700">(</span><span style="color: #0000BB">1.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.5</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setLeftFill</span><span style="color: #007700">(</span><span style="color: #0000BB">$f</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">movePenTo</span><span style="color: #007700">(-</span><span style="color: #0000BB">$width</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">$height</span><span style="color: #007700">/</span><span style="color: #0000BB">4</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drawLine</span><span style="color: #007700">(</span><span style="color: #0000BB">$width</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drawLine</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$height</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drawLine</span><span style="color: #007700">(-</span><span style="color: #0000BB">$width</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drawLine</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">$height</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$s&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getShape2</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$f&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addFill</span><span style="color: #007700">(</span><span style="color: #0000BB">$b</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SWFFILL_TILED_BITMAP</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;these&nbsp;two&nbsp;have&nbsp;no&nbsp;effect!<br /></span><span style="color: #0000BB">$f</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">moveTo</span><span style="color: #007700">(-</span><span style="color: #0000BB">$width</span><span style="color: #007700">/</span><span style="color: #0000BB">4</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">$height</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$f</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">scaleTo</span><span style="color: #007700">(</span><span style="color: #0000BB">0.5</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1.0</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setLeftFill</span><span style="color: #007700">(</span><span style="color: #0000BB">$f</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">movePenTo</span><span style="color: #007700">(-</span><span style="color: #0000BB">$width</span><span style="color: #007700">/</span><span style="color: #0000BB">4</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">$height</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drawLine</span><span style="color: #007700">(</span><span style="color: #0000BB">$width</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drawLine</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$height</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drawLine</span><span style="color: #007700">(-</span><span style="color: #0000BB">$width</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drawLine</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">$height</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SWFMovie</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setDimension</span><span style="color: #007700">(</span><span style="color: #0000BB">$width</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$height</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">add</span><span style="color: #007700">(</span><span style="color: #0000BB">$p</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$i</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">moveTo</span><span style="color: #007700">(</span><span style="color: #0000BB">$width</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$height</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /><br />for&nbsp;(</span><span style="color: #0000BB">$n</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$n</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">1.001</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$n</span><span style="color: #007700">+=</span><span style="color: #0000BB">0.03</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setRatio</span><span style="color: #007700">(</span><span style="color: #0000BB">$n</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">nextFrame</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;application/x-shockwave-flash'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">output</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-swfshape.addfill-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="swfshape.setleftfill.html" class="function" rel="rdfs-seeAlso">SWFShape::setLeftFill()</a> - Sets left rasterizing color</span></li>
    <li class="member"><span class="function"><a href="swfshape.setrightfill.html" class="function" rel="rdfs-seeAlso">SWFShape::setRightFill()</a> - Sets right rasterizing color</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.swfshape.html">SWFShape</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="swfshape.construct.html">SWFShape::__construct</a></div>
 <div class="up"><a href="class.swfshape.html">SWFShape</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
